<template>
    <c-list-template title="退税结算" :operation="true">
        <template slot="search">
            <el-row :gutter="24">
                <el-col :span="6" class="flex-center ">
                    <div class="mr-lg">出口申请单号</div>
                    <el-input v-model="querys.carOutApplyId" placeholder="请输入订单号" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center">
                    <div class="mr-lg">供应商名称</div>
                    <el-input v-model="querys.sellerName" placeholder="请输入卖家企业名称" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center">
                    <div class="mr-lg">状态</div>
                    <el-select v-model="querys.status" placeholder="请选择" class="wh flex-1 mr-lg">
                        <el-option label="待退税" value="0"></el-option>
                        <el-option label="已退税" value="1"></el-option>
                    </el-select>
                </el-col>
                <el-col :span="6" class="flex-x-end ">
                    <el-button icon="el-icon-search" type="primary" @click="handleSelect">搜索</el-button>
                    <el-button icon="el-icon-delete" @click="handleReset">重置</el-button>
                </el-col>
            </el-row>
        </template>
        <!-- <template slot="operation">
            <el-button icon="el-icon-plus" type="primary" @click="handleAdd">确认付款</el-button>
            <el-button icon="el-icon-plus" type="primary" @click="handleAdd">未付款</el-button>
        </template> -->
        <template slot="list">
            <el-table :header-cell-style="{ background: '#F1F1F1', color: '#092132' }" :data="tableData" v-loading="loading">
                <el-table-column label="序号" align="center" width="80" type="index" />
                <el-table-column label="出口申请单号" width="200" align="center" prop="carOutApplyId" />
                <el-table-column label="供应商名称" width="250" align="center" prop="sellerName" />
                <el-table-column label="出口国家" width="150" align="center" prop="endHarborCountry" />
                <el-table-column label="银行名称" align="center">
                    <template slot-scope="scope">
                        {{scope.row.sellerBankList == null ? "-": scope.row.sellerBankList.bankName }}
                    </template>
                </el-table-column>
                <el-table-column label="账户名称" align="center">
                    <template slot-scope="scope">
                        {{scope.row.sellerBankList == null ? "-": scope.row.sellerBankList.accountName }}
                    </template>
                </el-table-column>
                <el-table-column label="银行账号" align="center">
                    <template slot-scope="scope">
                        {{scope.row.sellerBankList == null ? "-": scope.row.sellerBankList.accountNo }}
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.timeCreate | dateYMDHMSFormat }}
                    </template>
                </el-table-column>
                <el-table-column label="状态" width="150" align="center">
                    <template slot-scope="scope">
                        {{scope.row.status == null ? "":taxStatus[scope.row.status].label}}
                    </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" align="center">
                    <template slot-scope="scope">
                        <el-link type="primary" v-if="scope.row.billUrl != null && scope.row.payUrl != null" @click="handleDetails(scope.row)">查看退税明细</el-link>
                        <el-link type="primary" v-if="scope.row.billUrl == null" @click="handleTaxUpload(scope.row)">上传退税单</el-link>
                        <el-link type="primary" v-if="scope.row.sellerBankId != null && scope.row.payUrl == null" @click="handleVoucherUpload(scope.row)">上传支付凭证</el-link>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <template slot="pagination">
            <el-pagination background :current-page="querys.current" :page-sizes="[10, 20, 50, 100]" :page-size="querys.size" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </template>

        <c-tax-upload ref="cTaxUpload" />
        <c-voucher-upload ref="cVoucherUpload" />
        <c-tax-details ref="cTaxDetails" />
    </c-list-template>
</template>
<script>
import { taxStatus } from "@/utils/status.js";
import cTaxUpload from "./components/c-tax-upload.vue";
import cVoucherUpload from "./components/c-voucher-upload.vue";
import cTaxDetails from "./components/c-tax-details.vue";
export default {
    components: {
        cTaxUpload,
        cVoucherUpload,
        cTaxDetails
    },
    data () {
        return {
            total: 0,
            tableData: [],
            querys: {
                current: 1,
                size: 10,
            },
            taxStatus: taxStatus,
            loading: false,
        };
    },
    mounted () {
        this.tableList();
    },
    methods: {
        handleVoucherUpload (item) {
            this.$refs.cVoucherUpload.handleOpen(item);
        },
        handleTaxUpload (item) {
            this.$refs.cTaxUpload.handleOpen(item);
        },
        handleChargeMoney (item) {
            this.$refs.cChargeMoney.handleOpen(item);
        },
        handleAdd () {
            this.$refs.cDealerForm.handleOpen();
        },
        handleEdit (item) {
            item.view = false
            this.$refs.cDealerForm.handleOpen(item);
        },
        handleDetails (item) {
            this.$refs.cTaxDetails.handleOpen(item);
        },
        tableList () {
            this.loading = true;
            const params = JSON.parse(JSON.stringify(this.querys));
            const url = "/sellerTaxRefundList/page";
            this.$get({ url, params }).then((res) => {
                this.tableData = res.records;
                this.total = res.total * 1;
                this.loading = false;
            });
        },
        handleReset () {
            this.querys = {
                current: 1,
                size: 10,
            };
            this.tableList();
        },
        handleSelect () {
            this.querys.current = 1;
            this.tableList();
        },
        handleSizeChange (val) {
            this.querys.size = val;
            this.tableList();
        },
        handleCurrentChange (val) {
            this.querys.current = val;
            this.tableList();
        },
    },
};
</script>
